//Plex.Lib.JS.load('UI.Widget.Fly_Window');


Plex.Util.Ad_Tester = function (objName)
{
	var self = this;
	this.window = new Plex.UI.Widget.Fly_Window({
		title:"Testing Banner Ad... Please Wait...",
		onclose:function()
		{
			self.onclose();
		}
	});
	
	this.window.box.settings.moveEffect=false;
	this.el = {};
	this.onclose = function(){}
	this.onResult = function(result){}
	this.onFailure = function(){}
	this.width = 0;
	this.height = 0;
	
	


	this.el.tester = new Element('embed',{
		'bgcolor':'#CCCCCC',
		'id':'EmbedFlashFilesUpload',
		'quality':'high',
		'pluginspage':'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash',
		'type':'application/x-shockwave-flash',
		'width':0,
		'height':0
	});
	
	self.el.tester.injectInside(self.window.body);
	
	this.test = function(fileId, type)
	{
		if(type == 1)
		{
			self.width = 565;
			self.height = 130;
		}
		else if(type == 2)
		{
			self.width = 800;
			self.height = 250;		
		}
		else if(type == 3)
		{
			self.width = 630;
			self.height = 170;
		}
		else if(type == 4)
		{
			self.width = 800;
			self.height = 600;
		}
		else if(type == 5)
		{
			self.result(true);
			return true;
		}
		
		self.el.tester.src='/handlers/Swf/Ad/Test_Ad.php?object='+objName+'&file='+Plex.Com.Image.getURL(fileId)+'&width='+self.width+'&height='+self.height;
		self.el.tester.width=self.width;
		self.el.tester.height=self.height;
		
		self.window.open(this.width,this.height);
	}

	this.open = function()
	{
		self.window.open();
	}
	
	this.result = function(result)
	{
		self.onResult(result);
	}

	this.close = function()
	{
		self.el.tester.src='/handlers/Swf/Ad/Blank.php';
		self.window.close();
	}
}